package com.xinqi.modules.databank.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.databank.client.CourseResourceClient;
import com.xinqi.modules.databank.dto.req.CourseResourceUpdateDTO;
import com.xinqi.modules.databank.dto.rsp.CourseInteractionSubmitResult;
import com.xinqi.modules.databank.dto.rsp.ResourceResponseDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 班级降级处理
 *
 * @author: system
 * @date: 2023/01/12
 */
@Slf4j
@Component
public class CourseResourceFallbackFactory implements FallbackFactory<CourseResourceClient> {

    @Override
    public CourseResourceClient create(Throwable cause) {
        return new CourseResourceClient() {

            @Override
            public R<ResourceResponseDTO> getResourceInfo(Long contentId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<String> update(Long id, CourseResourceUpdateDTO dto) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

            @Override
            public R<String> joinClass(Long classId, Long studentId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
